#include <iostream>
#include <signal.h>
#include <unistd.h>


volatile int gflags = 0;

void changedata(int signo)
{
    std::cout << "get a signo:" << signo << ", change gflag 0->1" << std::endl;
    gflags = 1; 
}

int main()
{
    signal(2, changedata);
    while(!gflags);

    std::cout << "process quit normal" << std::endl;
    return 0;
}